<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@taglib uri="/struts-tags" prefix="s"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>订单</title>
<link rel="stylesheet" href="${pageContext.request.contextPath}/common/style/base.css" type="text/css" media="screen" />
<link rel="stylesheet" href="${pageContext.request.contextPath}/common/style/page.css" type="text/css" media="screen" />
<link rel="stylesheet" href="${pageContext.request.contextPath}/common/src/css/jscal2.css" type="text/css" media="screen" />
<script src="${pageContext.request.contextPath}/common/js/jquery-1.7.2.min.js" type="text/javascript"></script>
<script src="${pageContext.request.contextPath}/common/js/common.js" type="text/javascript"></script>
<script src="${pageContext.request.contextPath}/common/src/js/jscal2.js" type="text/javascript"></script>
<script src="${pageContext.request.contextPath}/common/src/js/lang/cn.js" type="text/javascript"></script>
 <script>
	$(function(){
		var state="<s:property value='#parameters.state'/>";
		$("#condition a").removeClass("selected");
		
		if(state!=""&&state==0){
			$("#condition a").eq(5).addClass("selected");
			return;
		}
		
		$("#condition a").eq(state).addClass("selected");	
	});
	
	function edit(){
		var iframe = $(this.iframe).contents();	 
		closedialog();
		return false;
	}
</script>
<style>
#pagemenu #condition{
	position:absolute;
	right:10px;
}
</style>
</head>
<body>
<div id="main_frame">	
<div id="pagemenu">
	<a href="javascript:void(0);" title="订单列表"  class="selected">订单列表</a>
	|<a href="javascript:void(0);"  class="searchlink"  title="搜索">搜索</a>
	<span id="condition" >
	快速查询：
	<a href="getOrderListByPage.action" class="selected">全部</a>
	<a href="getOrderListByPage.action?state=1" >未付款</a>
	<a href="getOrderListByPage.action?state=2" >已付款</a>
	<a href="getOrderListByPage.action?state=3" >已发出</a>
	<a href="getOrderListByPage.action?state=4" >已确认</a>
	<a href="getOrderListByPage.action?state=0" >已取消</a>
	
	</span>
</div>
	<div class="searchbox" style="display:none">
		<form action="search.action" method="post">
		下单时间：<input type="text" class="dateinput1" id="orderdate" name="orderdate"/>
		<script type="text/javascript">
			Calendar.setup({
				inputField : "orderdate",
				trigger    : "orderdate",
				dateFormat: "%Y-%m-%d",
				minuteStep: 1,
				onSelect   :  function() {
					this.hide();
				}
			});
		</script>
		订单号：<input type="text" class="tx5" name="key"  value=''/>
		状态：<select name="state">
			<option value="" selected="selected">全部</option>
			<option value="1">未付款</option>
			<option value="2">已付款</option>
			<option value="3">已发出</option>
			<option value="4">已确认</option>
			<option value="0">已取消</option>
		</select>
		<input type="submit" value="搜索" class="cancelbtn" style="margin-top:0;"/>
		</form>
	</div>
	<div class="listbox">	
	<table class="listtab"  align="center">
		<thead>
			<tr>
				<th width="100"><span class="mline">订单号</span></th>
				<th width="100"><span class="mline">用户名称</span></th>
				<th width="80"><span class="mline">原金额</span></th>
				<th width="80"><span class="mline">最终金额</span></th>
				<th width="130"><span class="mline">下单时间</span></th>
				<th width="130"><span class="mline">付款时间</span></th>
				<th width="130"><span class="mline">发出时间</span></th>
				<th width="130"><span class="mline">确认时间</span></th>
				<th><span class="mline">状态</span></th>
				<th width="180">管理操作</th>
			</tr>
		</thead>
		<tbody>			
		<s:iterator value="orderlist" var="x">
			<tr>				
				<td><a href="findInfoById.action?id=${x.id}" title="订单详情">${x.id}</a></td>
				<td>${x.username}</td>
				<td>${x.price/100}元</td>
				<td>${x.currentPrice/100}元</td>
				<td><s:date name="#x.orderTime" format="yyyy-MM-dd HH:mm:ss"/></td>
				<td><s:date name="#x.payTime" format="yyyy-MM-dd HH:mm:ss"/></td>
				<td><s:date name="#x.sendTime" format="yyyy-MM-dd HH:mm:ss"/></td>
				<td><s:date name="#x.acceptTime" format="yyyy-MM-dd HH:mm:ss"/></td>
				<td>
					<s:if test="#x.state==1">
					<font color="red">未付款</font>
					</s:if>
					<s:elseif test="#x.state==2">
					<font color="green">已付款</font>
					</s:elseif>
					<s:elseif test="#x.state==3">
					<font color="green">已发货</font>
					</s:elseif>
					<s:elseif test="#x.state==4">
					<font color="green">已确认</font>
					</s:elseif>
					<s:else>
					<font color="green">已取消</font>
					</s:else>
				</td>
				<td>
					<a href="findInfoById.action?id=${x.id}" class="abg">详情</a>
					<s:if test="#x.state==1">
						<a href="updateState.action?id=${x.id}&state=2" onclick="return oconfirm();" class="abg">付款</a>
						<a href="updateState.action?id=${x.id}&state=0" onclick="return oconfirm();" class="abg">取消</a>
					</s:if>
					<s:if test="#x.state==2">						
						<a href="updateState.action?id=${x.id}&state=3" onclick="return oconfirm();" class="abg">发货</a>		
					</s:if>
					<s:if test="#x.state==3">
						<a href="updateState.action?id=${x.id}&state=4" onclick="return oconfirm();" class="abg">确认</a>			
					</s:if>
					<script>
						function oconfirm(){
							if(confirm("确定更改吗"))return true;
							else return false;
						}
					</script>
				</td>
			</tr>
		</s:iterator>
		</tbody>
	</table>
</div>
</div>
<div id="bottombar">
	<div class="fr listpage">${pagination}</div>
</div>
</body>
</html>